#!/bin/sh

LEVEL=$1
ORG=$2
PREFIX=$3
WEBDIR=/var/www

VER=0.9.2

if [ -z "${ORG}" ] ; then
	ORG="Hackmasters.net"
fi

if [ -z "${LEVEL}" ] ; then
	LEVEL=ca
fi

if [ -z "${PREFIX}" ] ; then
	PREFIX=/usr/local/openca/${ORG}/${VER}/${LEVEL}
fi

echo "Configuring with following parameters:"
echo "Prefix:         $PREFIX"
echo "Organization:   $ORG"
echo "Level:          $LEVEL"
echo ""

echo "(waiting 2 secs...)"
echo ""
sleep 2;

./configure \
  --prefix=${PREFIX} \
  --with-httpd-user=httpd \
  --with-httpd-group=websrc \
  --with-openssl-prefix=/usr/local/openssl.0.9.7b \
  --with-openca-prefix=${PREFIX}/openca \
  --with-module-prefix=${PREFIX}/modules \
  --with-etc-prefix=${PREFIX}/openca/etc \
  --with-httpd-fs-prefix=${WEBDIR} \
  --with-htdocs-url-prefix=/openca/${ORG}/${VER} \
  --with-htdocs-fs-prefix=${WEBDIR}/htdocs/openca/${ORG}/${VER} \
  --with-cgi-url-prefix=/cgi-bin/openca/${ORG}/${VER} \
  --with-cgi-fs-prefix=${WEBDIR}/cgi-bin/openca/${ORG}/${VER} \
  --with-module-prefix=${PREFIX}/modules \
  --with-engine=no \
  --with-web-host=localhost \
  --with-ca-organization="Hackmasters.net" \
  --with-ca-country=IT \
  --with-ldap-port=389 \
  --with-ldap-root="cn=Manager,o=HackMasters.net,c=IT" \
  --with-ldap-root-pwd="openca" \
  --enable-ocspd \
  --enable-scep \
  --disable-db \
  --enable-dbi \
  --disable-rbac \
  --with-hierarchy-level=${LEVEL} \
  --with-service-mail-account="support@hackmasters.net"

